package com.mx.tool.form.window.zh;

import cn.hutool.core.net.URLDecoder;
import cn.hutool.core.net.URLEncoder;
import cn.hutool.core.text.UnicodeUtil;
import org.apache.commons.lang3.StringUtils;

import javax.swing.*;
import java.nio.charset.Charset;
import java.util.Locale;

/**
 * @Author: 徐建鹏.
 * @create: 2021-11-10 14:40
 * @Description:
 */
public class UnicodeWindow {
    private JPanel jPanel;
    private JTextArea contentArea;
    private JTextArea showArea;
    private JButton jamButton;
    private JButton jemButton;
    private JCheckBox asciiBox;
    private JButton clearButton;
    private JButton hhButton;

    public UnicodeWindow() {
        jamButton.addActionListener(e -> {
            String content = contentArea.getText();
            if(StringUtils.isNotBlank(content)){
                showArea.setText(UnicodeUtil.toUnicode(content,asciiBox.isSelected()));
            }
        });
        jemButton.addActionListener(e -> {
            String content = contentArea.getText();
            if(StringUtils.isNotBlank(content)){
                showArea.setText(UnicodeUtil.toString(content));
            }
        });
        clearButton.addActionListener(e -> {
            contentArea.setText("");
            showArea.setText("");
        });
        hhButton.addActionListener(e -> {
            String content = contentArea.getText();
            String show = showArea.getText();
            contentArea.setText(show);
            showArea.setText(content);
        });
    }

    public JPanel getContent() {
        return jPanel;
    }
}
